<?php
// These two lines are a bit complicated. If I'm connecting to the server from
// localhost or custom name, the site
// is put in dev mode, otherwise it is put in live mode. Most sites would only
// need to put the site in either dev or live mode, thus wont need the IP checks
global $database;

if(isset($_SERVER['SERVER_NAME']) && ($_SERVER['SERVER_NAME'] == 'localhost' || $_SERVER['SERVER_NAME'] == 'dev.www.bjgarden.com')){
    $database = 'www_bjgarden_com';
    
    /* Database connection */
    define('SS_DATABASE_SERVER', 'localhost');
    define('SS_DATABASE_USERNAME', 'root');
    define('SS_DATABASE_PASSWORD', '');
    
    define('SS_DATABASE_PREFIX', '');

    define('SS_ENVIRONMENT_TYPE', 'dev');
    
    // This is used by sake to know which directory points to which URL
    global $_FILE_TO_URL_MAPPING;
    $_FILE_TO_URL_MAPPING[dirname( __FILE__ )] = 'http://dev.www.bjgarden.com';
}
else if(isset($_SERVER['SERVER_NAME']) && $_SERVER['SERVER_NAME'] == 'staging.bjcity.com'){
    $database = 'staging_bjcity';
    
    /* Database connection */
    define('SS_DATABASE_SERVER', 'localhost');
    define('SS_DATABASE_USERNAME', 'aio');
    define('SS_DATABASE_PASSWORD', '');

    define('SS_DATABASE_PREFIX', 'aio_');

    define('SS_ENVIRONMENT_TYPE', 'test');
    define('SS_USE_BASIC_AUTH', true);
    
    // This is used by sake to know which directory points to which URL
    global $_FILE_TO_URL_MAPPING;
    $_FILE_TO_URL_MAPPING[dirname( __FILE__ )] = 'http://staging.bjcity.com';
}
else{
    $database = 'bjcity';
    
    /* Database connection */
    define('SS_DATABASE_SERVER', 'localhost');
    define('SS_DATABASE_USERNAME', 'root');
    define('SS_DATABASE_PASSWORD', 'root');

    define('SS_DATABASE_PREFIX', '');
    
    define('SS_ENVIRONMENT_TYPE', 'live');
    
    // This is used by sake to know which directory points to which URL
    global $_FILE_TO_URL_MAPPING;
    $_FILE_TO_URL_MAPPING[dirname( __FILE__ )] = 'http://member.bjcity.com';
}

// These two defines sets a default login which, when used, will always log
// you in as an admin, even creating one if none exist.
define('SS_DEFAULT_ADMIN_USERNAME', 'aioadmin');
define('SS_DEFAULT_ADMIN_PASSWORD', 'p@55w0rd');

// This causes errors to be written to the silverstripe.log file in the same directory as this file, so /var.
// Before PHP 5.3.0, you'll need to use dirname(__FILE__) instead of __DIR__
define('SS_ERROR_LOG', '/logs/error.log');
